<?php
/**
 * 我的订单
 * User: tengyu
 * Date: 2017/8/29
 * Time: 20:46
 */?>
@extends('common.common')
@section('title','订单-个人中心')
@section('css')
    <link rel="stylesheet" href="{{url('/css/personal_order.css')}}">
@endsection
@section('js')
    <script src="{{asset('/js/personal_order.js')}}"></script>
    <script>
        /**订单详情删除*/
        function delete_order(dt_id)
        {
            $.ajax({
                url:'/user/order_delete/'+dt_id,
                type:'get',
                dataType:'json',
                success:function(res){
                    if(res.res=='ok'){
                        alert(res.msg);
                        history.go(0);
                    }else{
                        alert(res.msg);
                    }
                }
            });
        }
        /**未付款订单删除*/
        function delete_orders(id)
        {
            $.ajax({
                url:'/user/order_deletes/'+id,
                type:'get',
                dataType:'json',
                success:function(res){
                    if(res.res=='ok'){
                        alert(res.msg);
                        history.go(0);
                    }else{
                        alert(res.msg);
                    }
                }
            });
        }
        /**筛选数据*/
        function select_orderstatus(orderstatus)
        {
            if(orderstatus.length<1){
                window.location = '/user/order';
            }else{
                window.location = '/user/order?orderstatus=' + orderstatus
            }
        }
    </script>
@endsection
@section('content')
    <div id="content">
    <!--nav start-->
    @include('common.centernav')
    <!--nav end-->
        <h3>个人中心</h3>
        <div class="container">
            <div class="row">
            <!--sidebar start-->
            @include('usercenter.usersidebar')
            <!--sidebar end-->
                <!--2、右侧主体-->
                <div class="col-xs-9">
                    <!--右侧面版-->
                    <div id="panel" class="panel panel-default rightPanel">
                        <div class="panel-heading">
                            <h4 class="myorder">我的订单</h4>
                            <!--下拉框-->
                            <div class="dropdown pull-right">
                                <!--用户点击的标题-->
                                <button id="btnTitle" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    @if($param['request']['status']=='')全部状态@else{{ $param['orderstatus'][$param['request']['status']]}}@endif<span class="caret"></span>
                                </button>
                                <!--列表弹出来的内容-->
                                <ul class="dropdown-menu">
                                    <li value="">全部状态</li>
                                    @foreach($param['orderstatus'] as $k=>$v)
                                    <li value="{{$k}}">{{$v}}</li>
                                    @endforeach
                                </ul>
                            </div>
                        </div>
                        <div class="panel-body">
                            <ul class="product list-inline">
                                <li>商品信息</li>
                                <li>订单金额</li>
                                <li>订单状态</li>
                                <li>时长</li>
                            </ul>
                            <!--列表组-->
                            @if(count($param['orderlist'])>0)
                            @foreach($param['orderlist'] as $key=>$vaule)
                            <div class="orderTitle">
                                <p>
                                    <span>{{substr($param['orderlist'][$key][0]->created_at,0,10)}}</span>
                                    <span>订单号:{{$param['orderlist'][$key][0]->orders_orderNo}}</span>
                                    <span class="pull-right">{{$param['orderstatus'][$param['orderlist'][$key][0]->orders_status]}}</span>
                                </p>
                            </div>
                            @foreach($param['orderlist'][$key] as $v)
                            <ul class="orders list-inline">
                                    <li class="imgInfo"><div class="media">
                                            <div class="media-left">
                                                <img src="{{asset(env('STATIC_FILE_ERP_PATH').$v->fitment_details_imgOne)}}">
                                            </div>
                                            <div class="media-body">
                                                <p>{{$v->fitments_name}}*{{$v->details_fitment_number}}</p>
                                                <p>
                                                    <?php
                                                    $color=DB::table('fitment_color')->where('color_details_id',$v->details_id)->select('color_type')->get();
                                                    ?>
                                                    @foreach($color as $color_k=>$color_v)
                                                        <img src="{{$param['color'][$color_v->color_type]}}" alt="当前家具颜色">
                                                    @endforeach
                                                </p>
                                                <p>¥<span>@if($v->details_rent_type==1){{$v->details_nimbleprice}}@else{{$v->details_fixprice}}@endif</span>/月</p>
                                            </div>
                                        </div></li>
                                    @if($v->details_rent_type==1)
                                        <li>¥{{$v->details_fitment_number*$v->details_nimbleprice}}</li>
                                    @else
                                        <li>¥{{$v->details_fitment_number*$v->details_fixprice}}</li>
                                    @endif
                                    <li class="cancel">
                                        @if($param['orderlist'][$key][0]->orders_status<1)<p><a href="javascript:void(0);" onclick="delete_order({{$v->dt_id}})">取消订单</a></p>@else<p>已经支付</p>@endif
                                        @if($v->details_rent_type==1)<p>随租随还</p>@else<p>租满即送</p>@endif
                                    </li>

                                @if($v->details_rent_type==1)<li><span>12</span>个月</li>@else<li><span>18</span>个月</li>@endif
                                </ul>

                            @endforeach
                            <div class="orderDetail">
                                    <p><span>订单总额:¥</span><span>{{$param['orderlist'][$key][0]->orders_amount}}</span></p>
                                    <p>
                                        @if($param['orderlist'][$key][0]->orders_status<1)<a href="javascript:void(0);"><button class="btn btn-warning" onclick="delete_orders({{$param['orderlist'][$key][0]->order_id}})">取消订单</button></a>@endif
                                        <a href="javascript:void(0);"><button class="btn btn-warning" onclick="alert('等待接入信息')">物流信息</button></a>
                                        <a href="{{url('/user/orderdt/'.$param['orderlist'][$key][0]->order_id)}}"><button class="btn btn-danger">订单详情</button></a>
                                        @if($param['orderlist'][$key][0]->orders_status == '0')
                                        <a href="{{url('/paybill?id='.$param['orderlist'][$key][0]->order_id)}}"><button class="btn-danger btn">付款</button></a>
                                        @endif
                                    </p>
                                </div>
                            @endforeach
                            <div class="box-footer no-padding text-right" style="margin-right: 30px">
                                {!! $param['listpage']->appends(['orderstatus'=>$param['order_status']]) !!}
                            </div>
                                @else
                                <div class="text-center">
                                    <img src="{{asset('/img/771509094256_.pic.jpg')}}" alt="暂无数据">
                                </div>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="partition"></div>
@endsection
